package com.yeyks.modules.sys.controller;

import com.yeyks.account.dal.domain.AccountInfo;
import com.yeyks.common.utils.PageUtils;
import com.yeyks.common.utils.Result;
import com.yeyks.common.validator.ValidatorUtils;
import com.yeyks.commonReference.service.account.AccountInfoService;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 后台帐户表
 *
 * @author yyks
 * @email yyks
 * @date 2019-05-20 16:15:43
 */
@Api(tags = "账户模块")
@RestController
@RequestMapping("sys/accountinfo")
public class AccountInfoController {
    @Autowired
    private AccountInfoService accountInfoService;

    /**
     * 列表
     */

    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @RequiresPermissions("sys:accountinfo:list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = null;//accountInfoService.queryPage(params);

        return Result.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping(value = "/info/{id}", method = RequestMethod.POST)
    @RequiresPermissions("sys:accountinfo:info")
    public Result info(@PathVariable("id") Integer id){
        AccountInfo accountInfo = accountInfoService.getById(id);

        return Result.ok().put("accountInfo", accountInfo);
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @RequiresPermissions("sys:accountinfo:save")
    public Result save(@RequestBody AccountInfo accountInfo){
        accountInfoService.save(accountInfo);

        return Result.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @RequiresPermissions("sys:accountinfo:update")
    public Result update(@RequestBody AccountInfo accountInfo){
        ValidatorUtils.validateEntity(accountInfo);
        accountInfoService.updateById(accountInfo);
        
        return Result.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @RequiresPermissions("sys:accountinfo:delete")
    public Result delete(@RequestBody Integer[] ids){
        accountInfoService.removeByIds(Arrays.asList(ids));

        return Result.ok();
    }

}
